package com.fowo.api.service.handleWork;

import com.fowo.api.model.ship.plans.ShipPlansCancelExpeditingAction;
import com.fowo.api.model.ship.plans.ShipPlansVo;
import com.fowo.api.model.ship.plans.sub.ShipPlansSubItemVo;
import com.fowo.api.service.ShipPlansService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

@Component
public class ShipPlansCancelExpediting implements ShipPlansCancelExpeditingAction {

    @Resource
    private ShipPlansService shipPlansService;

    @Override
    public void run(List<Long> idList) throws Exception {
        for(Long id : idList){
            ShipPlansVo shipPlansVo = shipPlansService.getVoById(id);
            for(ShipPlansSubItemVo subItemVo : shipPlansVo.getProductList()){
                subItemVo.setIsUrgent(false);
            }
            shipPlansService.update(shipPlansVo);
        }
    }
}
